clc;clear;
n = 2;
% A=rand(n, n);
B=rand(n, n);B=-100*B*B';
C=rand(n, n);C=-100*C*C';
% D=rand(n, n);
A=[1000 0;0 1140];
D=[1 0;0 2];
M=[A, -B;-C, D];

b = rand(2*n, 1);
x = M\b;

b1 = b(1:n,1);
b2 = b(n+1:end,1);
x1 = zeros(n, 1);
x2 = zeros(n, 1);

for i=1:10
    x1 = A\(b1+B*x2);
    x2 = D\(b2+C*x1);
    err = norm(b-M*[x1;x2])
end